package com.xbj.dao;

import com.github.pagehelper.Page;
import com.xbj.model.News;
import com.xbj.model.User;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * Created by JzzZ
 * Date: 2018\7\1 0001
 * Time: 17:13
 * Project: News2.0
 * File description:测试类
 */

@RunWith(SpringJUnit4ClassRunner.class)

@ContextConfiguration(locations = {"classpath:config/applicationContext.xml"})
public class Test {

    @org.junit.Test
    public void selectToLogin() {
        UserDaoImpl userDao = new UserDaoImpl();
        User user = new User();
        user.setUsername("admin");
        user.setPassword("admin");
        User u = userDao.selectByUsernameAndPassword(user);
        System.out.println("user-->" + u);
    }

    @org.junit.Test
    public void selectById() {
        UserDaoImpl userDao = new UserDaoImpl();
        User user = userDao.selectUserById();
        System.out.println("user-->" + user);
    }


    //    ==============================================================
    @Autowired
    NewsDaoImpl newsDao;

    @org.junit.Test
    public void selectNews() {
        Page<News> newsPage = (Page<News>) newsDao.selectNews();
        long pageTotal = newsPage.getTotal();
    }
}
